# Copyright (c) 2018 Presto Labs Pte. Ltd.
# Author: jaewon

from coin.exchange.bitfinex_v2.order_gateway import BitfinexV2OrderGateway
from coin.exchange.bitfinex_v2.order_gateway_margin import BitfinexV2OrderGatewayMargin
from coin.strategy.mm.subscription import SubscriptionRequest
from coin.strategy.mm.base.order_subsystem import BaseOrderSubsystem


class BitfinexOrderSubsystem(BaseOrderSubsystem):
  OrderSubReq = SubscriptionRequest('Spot', 'Bitfinex', None)
  OrderGateway = BitfinexV2OrderGateway

  def _init_order_gateway(self):
    if self._og_params.use_margin_account:
      return super()._init_order_gateway(order_gateway_cls=BitfinexV2OrderGatewayMargin)
    else:
      return super()._init_order_gateway()
